package meng.springcloud.eureka.eurekaclient.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/")
public class HelloController {
	
	@Value("${server.port}")
	String port;

	@RequestMapping("/hello")
	@ResponseBody
	public String hello(@RequestParam String name) {
		return "hello " + name + ",i am from port:" + port;
	}

    /**
     * http://localhost:8024/boot/hello/method1?name=meng
     *
     * @param name
     * @return
     */
    @RequestMapping(value = "/method1", method = {RequestMethod.GET, RequestMethod.POST})
    public String method1(@RequestParam(value = "name", defaultValue = "mengzhang6") String name) {
        return "your name is " + name;
    }

    /**
     * http://localhost:8024/boot/hello/method2/world
     *
     * @param userName
     * @return
     */
    @GetMapping(value = "/method2/{userName}")
    // 相当于@RequestMapping(value = "/getDemo/{userName}", method = RequestMethod.GET)
    public String method2(@PathVariable String userName) {
        return "your name is " + userName;
    }


}